﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BuletinAnalyse.aspx.cs"
	Inherits="BuletinAnalyse" EnableEventValidation="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>HIPOCRATE - Buletin de investigatii paraclinice</title>
	<link rel="shortcut icon" href="<% = Request.ApplicationPath + "/images/favicon.ico" %>" />
	<link rel="stylesheet" type="text/css" href="../../../Styles/print.css" />
	<style type="text/css">
	@media print {
	.printhide { display:none; }
	}
	@media screen {
	.printonly { display:none; }
	}
	</style>
	<!-- as seen in "analyseFile_LAB.asp", this would allow manual page breaks... if it worked.
	@media screen .printTable { behavior: url(<% = Request.ApplicationPath + "/Template/apps/tableprint.htc" %>) }
	-->
</head>
<body bgcolor="#ffffff" onload="javascript:m_onLoad()">
	<form id="form1" runat="server">
	<asp:ScriptManager ID="ScriptManagerMaster" runat="server" EnableScriptGlobalization="true"
		AsyncPostBackTimeout="900" />
	<asp:UpdatePanel ID="up1" runat="server">
		<ContentTemplate>
			<div>
				<!-- BEGIN PAGE ANTET -- Application name, and buttons -->
				<table width="100%" border="0" id="pageAntet">
					<tr>
						<td align="left" valign="top">
							<!-- if instr(UCase(Request.ServerVariables("PATH_TRANSLATED")),"\CAS\")>0 -->
							<span class="banner">
								<% = Application["HNAME"] %>
								<br/>
							</span>
						</td>
						<td align="right" valign="top">
							<span class="printhide">
								<input type="button" title="" value="Imprima!" onclick="window.print()" style="border-width:0" />
								&nbsp;&nbsp;&nbsp;
								<input type="button" title="" value="Inapoi &lt;&lt;" onclick="history.back()" style="border-width:0" />
							</span>
							&nbsp;
						</td>
					</tr>
				</table>
				<!-- END PAGE ANTET -->

				<br/>
				<asp:Label ID="message" runat="server" />

				<!-- BEGIN PAGE BODY -->
				<table border="0" style="border-color:Red" width="100%">
					<thead style="display:table-header-group">
						<tr id="fileTitle">
							<td align="center" width="100%" colspan="3">
								<p align="center" style='text-align:center'>
									<span style='font-size:18.0pt; font-weight:bold'>
										Buletin de analize medicale
									</span>
								</p>

								<p align="center" style='text-align:center'>								
									<span style='font-size:10.0pt;font-family:Arial'>
										Data setului de analize <asp:Literal ID="strRequestedDate" runat="server" />
										<br/>
										Inregistrat de: <asp:Literal ID="strRequestorName" runat="server" />
									</span>
								</p>
							</td>
						</tr>
						<tr id="requestDetails">
							<td id="warning">
								&nbsp;
								<asp:Label ID="printNotAllowed" runat="server" Visible="false">
									<SPAN class="H2" style="width: 500px" nowrap>
										<font color="red">
											ACEASTA ESTE O VIZUALIZARE
											<br/>
											TIPARIREA ESTE INTERZISA
										</font>
									</SPAN>
									<br/><br/>
								</asp:Label>
								<font color="white">
									Pagina pregatita pentru tiparire.
								</font>
							</td>
							<td id="idCerere" align="right" nowrap="nowrap" colspan="2">
								<asp:Label ID="txtDuplicat" runat="server" Visible="false">
									<strong><u>DUPLICAT</u></strong>&nbsp;&nbsp;&nbsp;
								</asp:Label>
								Cod cerere:
								<strong>
									<asp:Literal ID="intCodeID" runat="server" />
								</strong>
								<!--
								&nbsp;&nbsp;&nbsp;&nbsp;
								<z align="center" style="text-align:center">
								<span style='font-size:24.0pt;font-family:"Free 3 of 9 Extended";mso-bidi-font-family:Arial'>
								< %=intCodeID%>
								</span>
								</z>
								-->
							</td>
						</tr>
						<tr id="pacientInfo">
							<!-- Se deseneaza o celula cu border linie neagra -->
							<td width="100%" colspan="3" style="border:solid windowtext 1.0pt; padding:0in 5.4pt 0in 5.4pt;">
								<table width="100%" style="font-size:10.0pt;font-family:'Times New Roman'">
									<tr>
										<td id="numePacient" style="font-size:12.0pt;font-family:'Times New Roman'">
											Nume:
											<strong><% = (strPacientName ?? "").ToUpper() %></strong>
										</td>
										<td id="age">
											Varsta:
											<strong><% = strPacientAge %></strong>
										</td>
										<td id="gender" style="width:20%">
											Sex:
											<strong><% = strPacientSex %></strong>
										</td>
										<td id="medic">
											Medic:
											<% = (strMedicName ?? "").ToUpper() %>
										</td>
										<td id="chitanta" rowspan="2" valign="middle">
											&nbsp;
											<asp:Label ID="zonaChitanta" runat="server" Visible="false">
												Nr chitanta:
												<strong>
													<asp:Literal ID="nrChitanta" runat="server" />
												</strong>
											</asp:Label>
										</td>
									</tr>
									<tr>
										<td id="cnp">
											C.N.P:
											<strong><% = strPacientCNP %></strong>
										</td>
										<td id="idPacient">
											Cod pacient:
											<strong><% = pacientID %></strong>
										</td>
										<td> &nbsp; </td>
										<td id="sectiePacient">
											Sectia:
											<strong><% = strPacientSection %></strong>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</thead>
					<tbody>
						<asp:Repeater ID="displayedResults" runat="server">
							<ItemTemplate>
<!-- analyseID = <asp:Literal id="analyseID" runat="server" />  -->
								<asp:PlaceHolder ID="newDomain" runat="server">
									<asp:PlaceHolder ID="closePreviousDomain" runat="server">
										<asp:PlaceHolder ID="domainCommentsArea" runat="server" Visible="false">
					<tr>
						<td colspan="3">
							<asp:Label Font-Italic="true" ID="domainCommentsText" runat="server" style="font-size:10.0pt;font-family:Arial;color:black" />
						</td>
					</tr>
										</asp:PlaceHolder>
										</tbody>
										<tfoot style="display:table-footer-group">
											<tr><td style="font-size:8.0pt;font-family:Arial;"><!-- &nbsp; --></td></tr>
										</tfoot></table>
										</p></td></tr>
									</asp:PlaceHolder>

			<tr><td colspan="3">
				<asp:Literal ID="domainTableContainer" runat="server" /> <%-- used to display: "<p id="P#" style="page-break-before: maybe" >" --%>
				<%-- p id="P<asp:Literal ID="domainCountOutput1" runat="server" />" style="page-break-before: <asp:Literal ID="pageBreakDecision" runat="server" />" --%>
				<table width="100%" <asp:Literal ID="domainTableID" runat="server" /> style="BORDER-RIGHT: #191970 1px solid;
					BORDER-TOP: #191970 1px solid;  FONT-SIZE: 11pt;    BORDER-LEFT: #191970 1px solid; BORDER-BOTTOM: #191970 1px solid;" >
				<thead style="display:table-header-group">
					<tr><td colspan="3" style="font-size:8.0pt;font-family:Arial;">&nbsp;</td></tr>
				</thead>
				<tbody>

				<tr><td <asp:Literal ID="domainDisplayClass" runat="server" Text="class='tdnplusleft'" /> colspan="3" valign="top">
					<b><span style='font-size:10.0pt;font-family:Arial;text-transform:uppercase;'>
						<asp:Literal ID="domainName" runat="server" />
					</span></b>

					<i><span style='font-size:8.0pt;font-family:Arial;text-transform:uppercase;'>
						<asp:Literal ID="validationInfo" runat="server" />
					</span></i>
				</td></tr>
								<!-- end of newDomain panel -->
								</asp:PlaceHolder>

								<!--tr>
									<td>
										<asp:Literal ID="repeatingOutput" Visible="false" runat="server" />
										&nbsp;
									</td>
								</tr-->
								<tr id="analyseHeaderWide" runat="server" visible="false">
									<td colspan="3" style="border:solid windowtext 1.0pt;mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;font-size:10.0pt">
										<span style="font-weight:bold">
											<asp:Literal id="AnalyseName" runat="server" />
										</span>
										<asp:Label id="AfisezPeBuletin" runat="server" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial Narrow';font-style:italic">
											(<asp:Literal id="machineTypeName" runat="server" />)
										</asp:Label>
									</td>
								</tr>

								<tr id="analyseTableHeader" runat="server" visible="false">
									<td align="center" style="width:33%;border:solid windowtext 1.0pt;mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;">
										<p><span style='font-size:8.0pt;color:black'>ANALIZE</span></p>
									</td>
									<td align="center" style="width:33%;border:solid windowtext 1.0pt;mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;">
										<p><span style='font-size:8.0pt;color:black'>REZULTATE</span></p>
									</td>
									<td align="center" valign="top" style="width:33%;border:solid windowtext 1.0pt;mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt;">
										<p><span style='font-size:8.0pt;color:black'>Interval de referinta / UM</span></p>
									</td>
								</tr>

								<asp:Repeater ID="rezultateAnaliza" runat="server">
									<ItemTemplate>
								<tr>
									<td style='BORDER-BOTTOM: black 1px solid;'>			
										<p>
											<span style="font-size:8.0pt;color:black;font-weight:bold">
												<asp:Literal id="RefName" runat="server" />
											</span>
											<asp:Label id="AfisezPeBuletin" runat="server" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Arial Narrow';font-style:italic">
												(<asp:Literal id="machineTypeName" runat="server" />)
											</asp:Label>
										</p>
									</td>
									<td align="center" style='font-size:8.0pt;color:black;BORDER-BOTTOM: black 1px solid;'>
										<b>
											<asp:Literal id="StringValue" runat="server" />
										</b>
										<asp:Image id="tooLow" runat="server" ImageUrl="~/Images/Lab/dr.gif" Visible="false" BorderWidth="0" Height="10" Width="10" />
										<asp:Image id="tooHigh" runat="server" ImageUrl="~/Images/Lab/ub.gif" Visible="false" BorderWidth="0" Height="10" Width="10" />
									</td>
									<td align="center" valign="top" style="BORDER-BOTTOM: black 1px solid;">	
										<p>
											<span style='font-size:8.0pt;color:black'>
												<asp:Literal id="interval" runat="server" />
												<asp:Literal id="umName" runat="server" />
											</span>
											&nbsp;
										</p>
									</td>
								</tr>
									</ItemTemplate>
								</asp:Repeater>

							</ItemTemplate>
						</asp:Repeater>

									<asp:PlaceHolder ID="closeLastDomain" runat="server">
										<asp:PlaceHolder ID="lastDomainCommentsArea" runat="server" Visible="false">
					<tr>
						<td colspan="3">
							<asp:Label Font-Italic="true" ID="lastDomainCommentsText" runat="server" style="font-size:10.0pt;font-family:Arial;color:black" />
						</td>
					</tr>
										</asp:PlaceHolder>
										</tbody>
										<tfoot style="display:table-footer-group">
											<tr><td colspan="3" style="font-size:8.0pt;font-family:Arial;"><!-- &nbsp; --></td></tr>
										</tfoot></table>
										</p></td></tr>
									</asp:PlaceHolder>

						<tr>
							<td id="D<%=lastDomainCount%>" colspan="3">
								<p id="P<%=lastDomainCount%>" style="page-break-before: always">
									&nbsp;
								</p>
							</td>
						</tr>
						<tr id="contentsOfLastPage">
							<td align="center" colspan="3">
								<% ++lastDomainCount; %>
								<p id="EndPage<%=lastDomainCount%>" style="page-break-before: always">
									<span class="H4" id="EndD<%=lastDomainCount%>">
										Sfarsit buletin de analize
										<br/>
										In caz de necesitate se efectueaza doar copia integrala a Buletinului de analize
										<br/>
										Rezultatele analizelor nu pot fi folosite la lucrari stiintifice decat cu acordul Sefului de Laborator
										<br/><br/><br/>&nbsp;
									</span>
								</p>
							</td>
						</tr>
					</tbody>
					<tfoot id="requestorDetails" style="display:table-footer-group">
						<tr>
							<td colspan="3"><hr/></td>
						</tr>
						<tr>
							<td id="requestor" style="font-size:8.0pt;color:black">
								<asp:Literal ID="txtForPrint" runat="server">Tiparit de:</asp:Literal>
								<asp:Literal ID="txtForView" runat="server">Afisat de:</asp:Literal>
								<asp:Literal ID="userName" runat="server" />
							</td>
							<td id="dateLabel" align="right" nowrap="nowrap" style="font-size:8.0pt;color:black">
								<asp:Literal ID="txtPrintDate" runat="server">Data tiparirii:</asp:Literal>
								<asp:Literal ID="txtViewDate" runat="server">Data afisarii:</asp:Literal>
							</td>
							<td id="dateValue" align="left" nowrap="nowrap" style="font-size:8.0pt;color:black">
								&nbsp;
								<asp:Literal ID="CurrentDate" runat="server" />
							</td>
						</tr>
						<tr id="formCode">
							<td style="font-size:8.0pt;color:black" colspan="3">
								Cod. BA-RGM-01, Editia 1, Revizia 0
							</td>
						</tr>
					</tfoot>
				</table>
				<!-- END PAGE BODY -->
				<asp:Panel ID="debuggingDetails" runat="server" Visible="false" style="background-color:Silver;border-color:Black;border-style:ridge">
					<asp:DataGrid ID="test" runat="server" AutoGenerateColumns="true" />
				</asp:Panel>

<%--@ Language=VBScript %><%

Response.Expires = -1441
Response.Buffer = True

Public strError, strAction

Public intCodeID

Public strSection
Public sql
Public userSection, userName
Public strRequestedDate, strRequestorName, strPacientCode
Public nrChitanta

--%>
<%-- Main

'************  Procedures  ********************************************

Sub Main ' Initiate page processing

	''' ValidatePage '''
	If Session("LOGIN") = "" or Session("Connection") = "" then _
		ShowErrorAndRedirect( "Pagina pe care ati cerut-o nu va este accesibila.", "/default.asp" )

	''' ValidateSecurity '''
	if not checkSecLevel(SEC_REPORTS) AND not checkSecLevel(SEC_ANALYSE_MANAGER) _
		AND not checkSecLevel(SEC_ANALYSE_DISPATCHER) AND not checkSecLevel(SEC_ANALYSE_PROCESSOR) _
		AND not checkSecLevel(SEC_ANALYSE_VIEWER) AND not checkSecLevel(SEC_LAB_ADMIN) then _
		ShowErrorAndRedirect( "Nu aveti suficiente drepturi pentru pagina ceruta.", "/main.asp" )

	''' ValidateParameters '''
	if Request.QueryString("id")&"" = "" OR not IsNumeric(Request.QueryString("id")&"") then _
		ShowErrorAndRedirect( "Parametrii incorecti.", "/main.asp" )

	if not OpenDBConnection() then _
		ShowErrorAndRedirect( "Conexiunea la baza de date nu poate fi deschisa.<br>" & Session("Error"), "/noAccess.asp" )
End Sub

--%>
			</div>
			<asp:PlaceHolder runat="server" ID="phReport" />
		</ContentTemplate>
	</asp:UpdatePanel>

    <script language="javascript" type="text/javascript">
	function m_onLoad() {
		var tbl;
		var p;
		var index = 0;
		var hIndex = 0, oh = 0, fp = 0;
		var maxH_p1 = 540, maxH_all = 680, maxH; //values for -> page setup: top 0.2, bottom = 0.2 Letter or A4 //maxH_p1=550
		var pageNo = 1;
		while (1) {
			index++;
			tbl = document.getElementById("D" + index);
			p = document.getElementById("P" + index);
			//		alert(findPosx(tbl));
			if (tbl != null) {
				oh = hIndex;
				hIndex = hIndex + findPos(tbl);
				if (pageNo == 1) {
					maxH = maxH_p1;
				} else {
					maxH = maxH_all;
				}
				if (hIndex > maxH) {
					pageNo++;
					hIndex = findPos(tbl);
					if (hIndex > maxH) {
						hIndex = hIndex % maxH;
					}

				} else {
					p.style.pageBreakBefore = "";
				}
			} else {
				break;
			}
		}
	}

	function findPos(obj) {
		var curleft = curtop = curBottom = curHeight = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft;
			curtop = obj.offsetTop;
			curHeight = obj.offsetHeight;
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
			curBottom = curtop + curHeight;
		}
		return curHeight;
	}

	function findPosx(obj) {
		var curleft = curtop = curBottom = curHeight = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft;
			curtop = obj.offsetTop;
			curHeight = obj.offsetHeight;
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
			curBottom = curtop + curHeight;
		}
		return [curleft, curtop, curBottom, curHeight];
	}
	</script>

	</form>
</body>
</html>
